package com.snailthink.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @program: springmvc-study
 * @description:
 * @author: SnailThink
 * @create: 2021-03-12 17:54
 **/
@Controller
public class SessionController {

	@RequestMapping("s1/t1")
	public String test1(HttpServletRequest request, HttpServletResponse response) {
		HttpSession session = request.getSession();
		System.out.println(session.getId());
		return "test";
	}

	/**
	 * 删除视图解析器
	 * @param model
	 * @return
	 */
	@RequestMapping("s1/t2")
	public String test2(Model model){
		model.addAttribute("msg","SessionController");
		//转发
		return "/WEB-INF/jsp/test.jsp";
	}


	/**
	 * 删除视图解析器
	 * @param model
	 * @return
	 */
	@RequestMapping("s1/t3")
	public String test3(Model model){
		model.addAttribute("msg","SessionController");
		//转发二
		return "forward/WEB-INF/jsp/test.jsp";
	}

	/**
	 * 删除视图解析器
	 * @param model
	 * @return
	 */
	@RequestMapping("s1/t4")
	public String test4(Model model){
		model.addAttribute("msg","SessionController");
		//重定向
		return "redirect:/index.jsp";
	}

}
